# -*- coding: utf-8 -*-
from django.shortcuts import render
from django.http import HttpResponse
from django.http import JsonResponse
from django.views.decorators.csrf import csrf_exempt
import os
from py2neo import Graph,Node,Relationship
import json
import configparser
import requests

cf = configparser.ConfigParser()
cf.read("./kg.conf")  # 读取配置文件，如果写文件的绝对路径，就可以不用os模块

@csrf_exempt
def  en_re_get(request):
    ctx = {}

    return render(request,"create_kg.html",{'ctx':ctx})
@csrf_exempt
def  kg_get(request):
    gettype=request.POST['type']
    getcont=request.POST['cont']
    addr = 'http://127.0.0.1:5051'
    url = addr + '/kg_create'
    ret = requests.post(url, data={'type':gettype,'cont':getcont})
    rdict=json.loads(ret.text)
    #print(rdict)
    return HttpResponse(json.dumps(rdict), content_type="application/json")
